//
//  HYImageTitleTableViewCell.m
//  Booking
//
//  Created by Maybe_文仔 on 2018/7/25.
//  Copyright © 2018年 Duntech. All rights reserved.
//

#import "HYImageTitleTableViewCell.h"
#import "HYTextFieldCellModel.h"

@interface HYImageTitleTableViewCell()
/** 标题 */
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UIImageView *iconImgView;
/** bottomLine */
@property (nonatomic,strong) UIView *bottomLine;

@end

@implementation HYImageTitleTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews{
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.iconImgView];
    [self addSubview:self.bottomLine];
}

- (void)layoutSubviews{
    [_iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self).offset(12 * WIDTH_MULTIPLE);
        make.centerY.equalTo(self);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.iconImgView.mas_right).offset(16 * WIDTH_MULTIPLE);
        
        make.top.bottom.equalTo(self);
    }];
    
    [_bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.bottom.equalTo(self);
        make.height.mas_equalTo(0.5);
    }];
}

-(void)configWithModel:(id)model{
    HYTextFieldCellModel *cellModel = (HYTextFieldCellModel *)model;
    self.titleLabel.text = cellModel.title;
    self.iconImgView.image = [UIImage imageNamed:cellModel.imageName];
}

#pragma mark -- lazyload

- (UILabel *)titleLabel{
    
    if (!_titleLabel) {
    
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = KFitFont(13);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.textColor = KCOLOR(@"272727");
    }
    return _titleLabel;
}


- (UIImageView *)iconImgView{
    
    if (!_iconImgView) {
        
        _iconImgView = [[UIImageView alloc] init];
        _iconImgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _iconImgView;
}

- (UIView *)bottomLine{
    
    if (!_bottomLine) {
        
        _bottomLine = [[UIView alloc] init];
        _bottomLine.backgroundColor = KAPP_SEPERATOR_COLOR;
    }
    return _bottomLine;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
